package com.learn.initbean.learnprocessor;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;

/**
 * @author daify
 * @date 2019-03-18
 */
public class MyPostProcessorTest02 {

    public static void main(String[] args) {
        //spring2 中注入BeanPostProcessorTest
        ClassPathResource resource = new ClassPathResource("spring2.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        BeanPostProcessorTest beanPostProcessorTest = new BeanPostProcessorTest();
        // 假如processor后
        factory.addBeanPostProcessor(beanPostProcessorTest);

        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        reader.loadBeanDefinitions(resource);
        BeanPostProcessorTest test = (BeanPostProcessorTest) factory.getBean("beanPostProcessorTest");
        test.display();
    }
}
